Ext.onReady(function(){
	block();
	var panel=new Ext.Panel({
		renderTo:"indexDiv",
		width:1200,
		height:700,
		layout:"table",
		layoutConfig: {
		columns: 3
		},
		items:[{html:"<div id='topDiv'></div>",colspan:3,height:137,width:1200},
		{html:"<div id='leftMenuDiv'></div>",height:500,width:200},
		{html:"<div id='naviDiv'style='height: 25px'></div><div id='contentDiv' class='content' style='height: 800px;'></div>",height:500,width:800},
		{html:"<div style='display: none' id='loginDivPanel'><div id='loginDiv'></div></div><div id='loginInfo' style='color: red; font-size: 12'></div>",height:500,width:200},
		{html:"<div id='bottomDiv'></div>",height:100,colspan:3,width:1200}
		
		] }
		);
		addTopDivContent();
		setCurUserName();
	unblock();
});

//给顶部div添加内容
function addTopDivContent(){
	load("topDiv","top.jsp",false,null);
	load("naviDiv","navi.jsp",false,function(){
	   doAfterReaady();
	   disChineseOrEnglishBtn();
	   hideCeswichBtn();
	   load("contentDiv","home.html",false,null);
	   bindEventAfterReady();
	});
	load("bottomDiv","bottom.jsp",false,null);
	load("leftMenuDiv","menu.jsp",false,function(){
	    createMenuPanel();
	});
}
//创建菜单面板
function createMenuPanel(){
        var goodsTypeInfo = findGoodsTypeInfo();
        createMenuTable(goodsTypeInfo);
        //var goodsTypeTitle = $i18n("menu.label");
		/***
		var panel=new Ext.Panel({
			renderTo:"menuDiv",
			title:goodsTypeTitle,
			width:200,
			height:200,
            border: false,
			layout:"accordion",
			layoutConfig: {
			   animate: true
			},
			items:goodsTypeInfo
		  }
		);**/
		
		

}
//设置当前登陆用户
function setCurUserName(){
  var userName = getCurUserName();
  if(userName != "" && userName != undefined && userName != null && userName != 'null'){
	  $("#loginInfo").html("欢迎您：" + userName + "<a href='javascript:exit()'>退出登陆</a>");
  }else{
      $("#loginInfo").html("您还未登陆，请<a href='javascript: createLoginInterface();'>登陆</a>");
  }
}
//国际化切换按钮调用的方法，将语言切换成英文
function ceswitch(){
   block();
   window.setTimeout(function(){
	   window.location.href = 'ceswich.action?countryCodeName=EN';
   },1000);
   unblock();
}


//退出登陆
function exit(){
   $.ajax({
      type: "GET",
      url:"exit.action",
      async:false,
      success: function(result){
          $("#loginInfo").html("您还未登陆，请<a href='javascript: createLoginInterface();'>登陆</a>");
      }
   });
}

//国际化切换按钮调用的方法,将语言切换成中文
function ceswitchToChinese(){
   block();
   window.setTimeout(function(){
       window.location.href = 'ceswich.action?countryCodeName=CN';
   },1000);
   unblock();
}

//页面加载完毕后执行这个方法
function doAfterReaady(){
    $("#ceswich").bind("click",function(){
       ceswitch();
    });
    
    $("#chinese").bind("click",function(){
       ceswitchToChinese();
    });
    
	$(".navi_td").each(function(){
		$(this).bind("mouseover",function(){
			addNaviBackground(this);
		});
		$(this).bind("mouseout",function(){
			reduceNaviBackground(this);
		});
		$(this).bind("click",function(){
			addNaviBackgroundAfterClick(this);
		});
	});
}
//隐藏中英文切换按钮之一
function hideCeswichBtn(){
   $.ajax({
      url:"findCurLanguge.action",
      async: false,
      type:"GET",
      success: function(result){
          if(result == "CN"){
              $("#ceswich").css("display","");
              $("#chinese").css("display","none");
          }else{
              $("#ceswich").css("display","none");
              $("#chinese").css("display","");
          }
      },
      error: function(request,error,status){
        showErrorMsg(error);
      }
   });
}

//显示中英文切换按钮
function disChineseOrEnglishBtn(){
   var href = window.location.href;
   if(href.indexOf("EN") >= 0){
       $("#ceswich").css("display","none");
       $("#chinese").css("display","");
   }else{
      $("#ceswich").css("display","");
      $("#chinese").css("display","none");
   }
}


 